home *** CD-ROM | disk | FTP | other *** search
/ NASA Climatology Interdisciplinary Data Collection / NASA Climatology Interdisciplinary Data Collection - Disc 3.iso / cdrom.gui < prev    next >
Text File  |  1998-04-06  |  14KB  |  278 lines

  1. #  cdrom.gui - last revision: Jan 14, 1998
  2. #
  3. #  Sample widget script for the CIDC CDROM.
  4. #
  5. #  How to invoke this script:
  6. #
  7. #  At startup. Set the enviroment variable GAGUI with the
  8. #  name of the script file, e.g., 
  9. #
  10. #  % setenv GAGUI cdrom.gui
  11. #
  12. #  At the GrADS command line prompt. Simply type
  13. #
  14. #  ga> gui cdrom.gui
  15. #
  16. #  Of course, you must have a version of GrADS built with
  17. #  Athena Widgets support.
  18. #
  19. #  (c) 1997 Arlindo da Silva   (dasilva@gsfc.nasa.gov)
  20. #
  21. #              *** Copy freely but DO NOT sell ***
  22. #
  23. #  See also sample.gui.
  24. #.........................................................................
  25.  
  26. #  Most "exec" commands are supported
  27. #  ----------------------------------
  28.    set gxout shaded
  29.  
  30. # A "label" is an inactive widget which display some text, 
  31. # e.g., an informative  title. The first argument, "root"
  32. # in this case, is the name you give to the widget so that
  33. # you can refer to it later on
  34. # -------------------------------------------------------
  35.   MakeLabel(root,"CIDC CDROM III")
  36.  
  37. # This command creates a dropdown menu called " File... "
  38. # as usual, the first argument "file" is the name of the
  39. # widget
  40. # -------------------------------------------------------
  41.   MakeMenu ( file, "File" )
  42.  
  43. # Once you make a memu, you create its items. For the first item:
  44. # --------------------------------------------------------------
  45.       MakeMenuItem(open, file, "Open", Load, "open")
  46.  
  47. # The parameters this particular item are:
  48. #     open    the name of the item widget
  49. #     file    the menu the item belongs to (see MakeMenu above)
  50. #     "Open"  This is the text it displays on the screen
  51. #     Load    this is the callback name, i.e., the widget invokes
  52. #             this function when pressed. This particular callback
  53. #             pops up a "file finder" widget, and after the user
  54. #             clicks on a file name it executes the grads command
  55. #             "open" (see last argument) on this file. A list
  56. #             of the other available callbacks can be found in the
  57. #             end of this file.
  58. #     "open"  Argument to be passed to the callback. In this 
  59. #             particular case, it is the GrADS command to be
  60. #             executed on the file.
  61. #  The definition of the other items in this menu follows.
  62.       MakeMenuItem(fsel, file, "File Selection ", FileSel, NULL )
  63.       MakeMenuItem(browse, file, "View Text File", Browse, NULL)
  64.       MakeMenuItem(junk, file, "_______________", NULL, NULL )
  65.       MakeMenuItem(exec, file, "Exec", Load, "exec")
  66.       MakeMenuItem(run, file, "Run", Load, "run")
  67.       MakeMenuItem(gui, file, "GUI", Load, "gui")
  68.       MakeMenuItem(junk, file, "_______________", NULL, NULL )
  69.       MakeMenuItem(init, file, "Reinit", Cmd, "reinit")
  70.       MakeMenuItem(exit, file, "Exit", Cmd, "quit")
  71.  
  72. # A menu with assorted internal options
  73. # -------------------------------------
  74.   MakeMenu ( options, "Options" )
  75.       MakeMenuItem(map, options, "Continental Boundaries on/off",  CmdStr, "set mpdraw " )
  76.       MakeMenuItem(tit, options, "Draw Title", CmdStr, "draw title " )
  77.       MakeMenuItem(cbar, options, "Color Bar", Cmd, "run cbarn" )
  78.       MakeMenuItem(junk, options, "_______________", NULL, NULL )
  79.       MakeMenuItem(shade, options, "Shaded", Cmd, "set gxout shaded" )
  80.       MakeMenuItem(cont, options, "Contour", Cmd, "set gxout contour" )
  81.       MakeMenuItem(grfill, options, "Grid Fill", Cmd, "set gxout grfill" )
  82.       MakeMenuItem(grvals, options, "Grid Values", Cmd, "set gxout grid" )
  83.       MakeMenuItem(vec, options, "Vector", Cmd, "set gxout vector" )
  84.       MakeMenuItem(line, options, "Line Plot", Cmd, "set gxout line" )
  85.       MakeMenuItem(bar, options, "Bar Chart", Cmd, "set gxout bar" )
  86.  
  87. # Creates simple buttons. Buttons work pretty much like menu items
  88. # but they do not belong to any menu and are directly clickable.
  89. # ------------------------------------------------------------------
  90.   MakeButton( clear, "Clear", Cmd, "clear" )
  91.   MakeButton( quit, "Quit", Cmd, "quit" )
  92.   MakeButton( prompt, "ga>", CmdWin, NULL )
  93.  
  94. # A menu for defining GrADS dimensions. This is very crude right now.
  95. # I will be developing a specific callback with rubber bands
  96. # etc. for these functions. Stay tuned. 
  97. # ------------------------------------------------------------------
  98.   MakeMenu( dim, "Dim")
  99.       MakeMenuItem(lat, dim, "Latitude", CmdStr, "set lat " )
  100.       MakeMenuItem(lon, dim, "Longitude", CmdStr, "set lon " )
  101.       MakeMenuItem(time, dim, "Time", CmdStr, "set time " )
  102.       MakeMenuItem(junk, dim, "_________", NULL, NULL )
  103.       MakeMenuItem(x, dim, "x", CmdStr, "set x " )
  104.       MakeMenuItem(y, dim, "y", CmdStr, "set y " )
  105.       MakeMenuItem(t, dim, "t", CmdStr, "set t " )
  106.  
  107. # Frequently used buttons (and toggle)
  108. # -----------------------------------
  109.   MakeButton( var, "Var", VarSel, NULL )
  110.   MakeToggle( hold, "Hold", FALSE, NULL, Toggle, "hold" )
  111.   MakeButton( prev, " << ", Display, "<<" )
  112.   MakeButton( displ, "Display", Display, "DISPLAY" )
  113.   MakeButton( next, " >> ", Display, ">>" )
  114.   MakeButton( rein, "Reinit", Cmd, "reinit")
  115.   MakeButton( fresh, "Fresh", Cmd, "  ")
  116.  
  117.  
  118. # CIDC CD-ROM I menu's
  119. # -------------
  120.   MakeMenu(rd, "Radiation")
  121.       MakeMenuItem(er, rd, "Erbe Outgoing longwave radiation",  Open, "open data/radiation_clouds/erbe_rad/erbe.lwolr.1nmegg.ctl" )      
  122.       MakeMenuItem(gs, rd, "GISS Surface solar irradiance",  Open, "open data/radiation_clouds/solrad_sw/giss.srfrad.1nmegg.ctl" )      
  123.  
  124.   MakeMenu(c2, "ISCCP C2 Clouds")
  125.       MakeMenuItem(cf, c2, "Cloud fraction",  Open, "open data/radiation_clouds/isccp_c2/cldfrc/isccp_c2.cldfrc.1nmegg.ctl" )     
  126.       MakeMenuItem(ct, c2, "Cloud top temperature",  Open, "open data/radiation_clouds/isccp_c2/cldtmp/isccp_c2.cldtmp.1nmegg.ctl" ) 
  127.       MakeMenuItem(cp, c2, "Cloud top pressure",  Open, "open data/radiation_clouds/isccp_c2/cldprs/isccp_c2.cldprs.1nmegg.ctl" ) 
  128.       MakeMenuItem(cr, c2, "Cloud optical thickness",  Open, "open data/radiation_clouds/isccp_c2/cldtau/isccp_c2.cldtau.1nmegg.ctl" )  
  129.       MakeMenuItem(sr, c2, "Clear sky surface reflectance",  Open, "open data/radiation_clouds/isccp_c2/srfref/isccp_c2.srfref.1nmegg.ctl" )    
  130.       MakeMenuItem(st, c2, "Clear sky surface temperature",  Open, "open data/radiation_clouds/isccp_c2/srftmp/isccp_c2.srftmp.1nmegg.ctl" )    
  131.  
  132.   MakeMenu(d2, "ISCCP D2 Clouds - Subset")
  133.       MakeMenuItem(cf, d2, "Cloud fraction",  Open, "open data/radiation_clouds/isccp_d2/cldfrc/isccp_d2.cldfrc.1nmegg.ctl" )     
  134.       MakeMenuItem(ct, d2, "Cloud top temperature",  Open, "open data/radiation_clouds/isccp_d2/cldtmp/isccp_d2.cldtmp.1nmegg.ctl" ) 
  135.       MakeMenuItem(cp, d2, "Cloud top pressure",  Open, "open data/radiation_clouds/isccp_d2/cldprs/isccp_d2.cldprs.1nmegg.ctl" ) 
  136.       MakeMenuItem(cr, d2, "Cloud optical thickness",  Open, "open data/radiation_clouds/isccp_d2/cldtau/isccp_d2.cldtau.1nmegg.ctl" )  
  137.       MakeMenuItem(cw, d2, "Cloud water path",  Open, "open data/radiation_clouds/isccp_d2/cldwpt/isccp_d2.cldwpt.1nmegg.ctl" )  
  138.       MakeMenuItem(sr, d2, "Clear sky surface reflectance",  Open, "open data/radiation_clouds/isccp_d2/srfref/isccp_d2.srfref.1nmegg.ctl" )    
  139.       MakeMenuItem(st, d2, "Clear sky surface temperature",  Open, "open data/radiation_clouds/isccp_d2/srftmp/isccp_d2.srftmp.1nmegg.ctl" )    
  140.  
  141.   MakeMenu(srb, "LARC Surface Radiation Budget")
  142.       MakeMenuItem(tds, srb, "Total-sky downward shortwave flux", Open, "open data/radiation_clouds/srb/swdwn/srb.swdwn.1nmegg.ctl" )
  143.       MakeMenuItem(cds, srb, "Clear-sky downward shortwave flux", Open, "open data/radiation_clouds/srb/swcs/srb.swcs.1nmegg.ctl" )
  144.       MakeMenuItem(tns, srb, "Total-sky net shortware flux", Open, "open data/radiation_clouds/srb/swnet/srb.swnet.1nmegg.ctl" )
  145.       MakeMenuItem(tdl, srb, "Total-sky downward longwave flux", Open, "open data/radiation_clouds/srb/lwdwn/srb.lwdwn.1nmegg.ctl" )
  146.       MakeMenuItem(cdl, srb, "Clear-sky downward longwave flux", Open, "open data/radiation_clouds/srb/lwcs/srb.lwcs.1nmegg.ctl" )
  147.       MakeMenuItem(tnl, srb, "Total-sky net longwave flux", Open, "open data/radiation_clouds/srb/lwnet/srb.lwnet.1nmegg.ctl" )
  148.       MakeMenuItem(clp, srb, "Cloud percentage", Open, "open data/radiation_clouds/srb/cp/srb.cp.1nmegg.ctl" )
  149.  
  150.   MakeButton(help, "Help", Browse, software/grads/help.txt)
  151.  
  152. # Once you define buttons and menus you may want to enforce their
  153. # relative position. The very first button is always placed at the
  154. # upper left corner.
  155. # ----------------------------------------------------------------
  156.  
  157.   # First row 
  158.   SetWidgetPos(file, PLACE_UNDER, root, NO_CARE, NULL)
  159.   SetWidgetPos(options, PLACE_UNDER, root, PLACE_RIGHT, file )
  160.   SetWidgetPos(dim, PLACE_UNDER, root, PLACE_RIGHT, options )
  161.   SetWidgetPos(prompt, PLACE_UNDER, root, PLACE_RIGHT, dim )
  162.   SetWidgetPos(help, PLACE_UNDER,   root, PLACE_RIGHT, prompt)
  163.  
  164.   # Second row
  165.   SetWidgetPos(rd, PLACE_UNDER, file, NO_CARE, NULL)
  166.   SetWidgetPos(c2, PLACE_UNDER, file, PLACE_RIGHT, rd)
  167.     
  168.   # Third row
  169.   SetWidgetPos(d2, PLACE_UNDER, rd, NO_CARE, NULL)
  170.  
  171.   # Forth row
  172.   SetWidgetPos(srb, PLACE_UNDER, d2, NO_CARE, NULL)
  173.  
  174.   # Fith row
  175.   SetWidgetPos(fresh, PLACE_UNDER, srb, NO_CARE, NULL )
  176.   SetWidgetPos(var, PLACE_UNDER, srb, PLACE_RIGHT, fresh )
  177.   SetWidgetPos(prev, PLACE_UNDER, srb, PLACE_RIGHT, var )
  178.   SetWidgetPos(displ, PLACE_UNDER, srb, PLACE_RIGHT, prev )
  179.   SetWidgetPos(next, PLACE_UNDER, srb, PLACE_RIGHT, displ )
  180.  
  181.   # Sixth row
  182.   SetWidgetPos(hold, PLACE_UNDER, fresh, NO_CARE, NULL )
  183.   SetWidgetPos(clear, PLACE_UNDER, fresh, PLACE_RIGHT, hold)
  184.   SetWidgetPos(rein, PLACE_UNDER, fresh, PLACE_RIGHT, clear )
  185.   SetWidgetPos(quit, PLACE_UNDER, fresh, PLACE_RIGHT, rein )
  186.  
  187. # In order to make your widgets appear on the screen you *must*
  188. # issue this command.
  189. # -------------------------------------------------------------
  190.   ShowDisplay()
  191.  
  192. # After your widgets appear on the screen, you can set the color 
  193. # of your widgets. The following colors are pre-defined:
  194. # white, back, red, green, blue, yellow.
  195. # --------------------------------------------------------------
  196.   GetNamedColor(gray,"grey")
  197.   GetNamedColor(Blue,"LightSkyBlue")
  198.   GetNamedColor(Green,"Green")
  199.   GetNamedColor(pink,"gold")         # pink is actually gold, get it?
  200.   AllFgColor(black)
  201.   AllBgColor(Blue)
  202.   SetBgColor(root,white)
  203.   SetFgColor(root,red)
  204.   SetBgColor(file,green)
  205.   SetBgColor(options,green)
  206.   SetBgColor(dim,green)
  207.   SetFgColor(prompt,yellow)
  208.   SetBgColor(prompt,red)
  209.   SetFgColor(help,yellow)
  210.   SetBgColor(help,red)
  211.   SetBgColor(prev,pink)
  212.   SetBgColor(displ,pink)
  213.   SetBgColor(next,pink)
  214.   SetBgColor(play,pink)
  215.   SetBgColor(fresh,pink)
  216.   SetBgColor(var,pink)
  217.   SetBgColor(hold,gray)
  218.   SetBgColor(clear,gray)
  219.   SetBgColor(reset,gray)
  220.   SetBgColor(rein,gray)
  221.   SetBgColor(quit,gray)
  222.  
  223. # And you must call this function at the end of your first GUI script.
  224. # This instructs the X Toolkit to enter an infinite loop, monitoring
  225. # keyboard and mouse events. Repeating: you *must* call MainLoop().
  226. # -------------------------------------------------------------------
  227.   MainLoop()
  228.  
  229. #........................................................................
  230. #
  231. # APPENDIX: Currently available callback functions
  232. #
  233. #     Browse    Opens a text file, such as a help file, on a separate
  234. #               window.
  235. #     Cmd       Executes a generic GrADS command
  236. #     CmdStr    Like Cmd, but the user is prompted for an additional
  237. #               string to be appended to the GrADS command.
  238. #     CmdWin    Invokes a window for GrADS command line interface.
  239. #               User can click on past commands from a list.
  240. #     CmdLine   Invokes the standard GrADS command line interface.
  241. #               When the command line is active the other widgets
  242. #               are not available (may be fixed in the future).
  243. # CloseWindow   Closes the current window (do not use for your primary
  244. #               window or you will get stuck).
  245. #     Display   A generic callback for displaying the current variable
  246. #               (or expression) set with VarSel. The options are:
  247. #                  <<    decrements time and executes display
  248. #                 PLAY   starts animation from current to last time
  249. #                DISPLAY just executes display
  250. #                  >>    increments time and  executes display
  251. #               If the "hold" toggle state is OFF (the default),
  252. #               the screen is cleared before displaying.
  253. #     Edit      Like browse, but the user can edit the file. This simple
  254. #               text editor is integrated with GrADS, providing a very
  255. #               elementary Integrated Development Enviroment (IDE) for
  256. #               GrADS scripts. In particular, the script being edited
  257. #               can be executed by clicking on a button (not
  258. #               implemented yet).
  259. #     FileSel   Pops up a scrollable list and asks the user to selected
  260. #               a file among the currently opened GrADS files (including
  261. #               SDFs). The selected file becomes the default.
  262. #     Load      Pops up a "file finder" widget, and after the user
  263. #               clicks on a file name it executes a GrADS command
  264. #               specified as the last argument. In case of "open" or 
  265. #               "sdfopen" the files becomes the default, and the
  266. #               user is asked to select a variable from this file.
  267. #     Open      Similar to Load, but the file name must be specified.
  268. #     Toggle    Turn internal options ON/OFF. The only internal
  269. #               option currently supported is "hold". This callback is
  270. #               usually used with MakeToggle(), see example above.
  271. #     VarSel    Pops up a scrollable list and asks the user to selected
  272. #               a variable from the default file. The user can also
  273. #               type a generic GrADS expression instead of selecting
  274. #               a single variable.
  275. #     NULL      Does not do anything, used for inactive buttons.
  276. #
  277. #........................................................................
  278.